package err

import (
	"gitee.com/injoyai/goutil/conv"
	"runtime/debug"
)

type Entity struct {
	text string
	//Append []string
	stack string
}

func New(i interface{}, stack ...bool) *Entity {
	return &Entity{
		text:  conv.String(i),
		stack: conv.SelectString(len(stack) > 0 && stack[0], string(debug.Stack()), ""),
	}
}

func (this *Entity) Error() string {
	if len(this.stack) > 0 {
		return this.text + "\n" + this.stack
	}
	return this.text
}

//func (this *Entity) Add(s ...interface{}) *Entity {
//	this.Append = append(this.Append, fmt.Sprint(s...))
//	return this
//}
